package com.ygg.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ygg.model.user.UserInfo;
import com.ygg.result.Result;
import com.ygg.service.UserInfoService;
import com.ygg.vo.user.UserInfoQueryVo;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.Map;

@RestController
@RequestMapping("/admin/user")
public class UserController {

    @Resource
    private UserInfoService userInfoService;

    @PostMapping("{page}/{limit}")
    public Result getPage(@PathVariable Integer page,
                          @PathVariable Integer limit,
                          @RequestBody UserInfoQueryVo userInfoQueryVo) {
        Page<UserInfo> data = userInfoService.getPage(page, limit, userInfoQueryVo);
        return Result.ok(data);
    }

    @ApiOperation(value = "锁定")
    @GetMapping("lock/{userId}/{status}")
    public Result lock(
            @PathVariable("userId") Long userId,
            @PathVariable("status") Integer status) {
        userInfoService.lock(userId, status);
        return Result.ok();
    }

    @ApiOperation(value = "详情")
    @GetMapping("show/{id}")
    public Result show(
            @PathVariable("id") Long userId) {
        Map<String,Object> map = userInfoService.userShow(userId);
        return Result.ok(map);
    }

    //认证审批
    @GetMapping("approval/{userId}/{authStatus}")
    public Result approval(@PathVariable Long userId,@PathVariable Integer authStatus) {
        userInfoService.approval(userId,authStatus);
        return Result.ok();
    }


}
